//
//  MainNavigationController.swift
//  LiveShow
//
//  Created by dai zhong on 2017/4/25.
//  Copyright © 2017年 company.cn. All rights reserved.
//

import UIKit

class MainNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        addAllScreenPanGesture();
        
    }

}

extension MainNavigationController{

    fileprivate func addAllScreenPanGesture(){
    
        // self.interactivePopGestureRecognizer is the Log:
        // Optional(<UIScreenEdgePanGestureRecognizer: 0x7fc3b241e820; state = Possible; delaysTouchesBegan = YES; view = <UILayoutContainerView 0x7fc3b2768b90>; target= <(action=handleNavigationTransition:, target=<_UINavigationInteractiveTransition 0x7fc3b241e3d0>)>>)
        
        guard let targets = self.interactivePopGestureRecognizer!.value(forKey: "_targets") as? [NSObject] else {
            return;
        }
        
        let targetObj = targets[0];
        let target = targetObj.value(forKey: "target");
        let action = Selector(("handleNavigationTransition:"));
        let panGesture = UIPanGestureRecognizer(target: target, action: action);
        self.view.addGestureRecognizer(panGesture);
    }
    
    override var preferredStatusBarStyle: UIStatusBarStyle{
    
        return UIStatusBarStyle.lightContent;
    }
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        if self.childViewControllers.count > 0{
        
            viewController.hidesBottomBarWhenPushed = true;
        }
        super.pushViewController(viewController, animated: animated);
    }
}






















